import { conductTopicProject } from '@/services/api/api-home';
import { Avatar, Card, Empty, Tag, Typography } from 'antd';
import moment from 'moment';
import { useEffect, useRef, useState } from 'react';
import { Link } from '@umijs/max';
import styles from '../../style.less';
import CardTitle from '@/components/CardTitle';
import { ActionType, ProList } from '@ant-design/pro-components';
import { pageCuesTopic } from '@/services/api/api-cues-topic';
import TableTableTopicRenderDetails from '@/pages/cues/topic/topic/table/TableTopicRenderDetails';

interface ConductTopicMediaProps {
  value?: any;
  onChange?: (value: any) => void;
}

const ConductTopicMedia: React.FC<ConductTopicMediaProps> = ({ value, onChange }) => {
  const [conductTopicData, setConductTopicDataState] = useState<CuesTopicData.TopicPage[]>([]);
  const userRefList = useRef<ActionType>();
  useEffect(() => {
    conductTopic();
  }, []);

  const conductTopic = async () => {
    const response = await conductTopicProject();
    if (response.code == 0) {
      setConductTopicDataState(response.data.data);
    }
  };
  /**
   * 请求网络
   * @param value
   */
  const request = async (params = {}) => {
    const response = await pageCuesTopic({ pageSize: 10, current: 1, mode: 2, run: 1 });
    return Promise.resolve({
      data: response.data.data,
      total: response.data.total,
      success: response.code === 0,
    });
  };
  /**
   * 初始化报表
   */
  useEffect(() => {
    // loadData();
  }, []);
  return (
    <Card
      className={styles.projectList}
      style={{ marginBottom: 24 }}
      title={<CardTitle>我的选题计划</CardTitle>}
      bordered
      extra={<Link to="/cues">全部</Link>}
      bodyStyle={{ padding: 0 }}
    >
      <ProList<CuesTopicData.TopicPage>
        header={false}
        headerTitle={false}
        // ghost={false}
        // itemCardProps={{
        //   ghost: false,
        // }}
        actionRef={userRefList}
        request={request}
        showActions="hover"
        grid={{ gutter: 18, column: 3 }}
        onItem={(record: any) => {
          return {
            onMouseEnter: () => { },
            onClick: () => { },
          };
        }}
        style={{margin:10}}
        renderItem={(item: CuesTopicData.TopicPage, index: number) => {
          return (
            <TableTableTopicRenderDetails
              item={item}
              onRefurbish={() => {
                userRefList.current?.reload();
              }}
              triggerMode="card"
              title={item.name}
            />
          );
        }}
        rowKey={'id'}
        toolBarRender={false}
      />
    </Card>
  );

};

export default ConductTopicMedia;





